package com.bluefox;

import com.bluefox.condition.LinuxCondition;
import com.bluefox.condition.WindowsCondition;
import com.bluefox.utils.SpringContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @EnableAsync 开启的是spring自己的线程池 可以使用  配置好线程池后  可以使用注解开启线程执行任务
 */
@Slf4j
@EnableAsync
@EnableJpaAuditing
@SpringBootApplication
@EnableTransactionManagement
public class SystemApplication {

    public static void main(String[] args) {

        SpringApplication.run(SystemApplication.class, args);
    }

    @Bean("linux")
    @Conditional(LinuxCondition.class)
    public SpringContextHolder springContextHolder() {
        log.info("加载linux");
        return new SpringContextHolder();
    }

    @Bean("windows")
    @Conditional(WindowsCondition.class)
    public SpringContextHolder springContextHolder2() {
        log.info("加载windows");
        return new SpringContextHolder();
    }
}
